<?php

namespace app\model\referral;

use app\BaseModel;
use app\model\UserModel;
use think\model\relation\BelongsTo;

/**
 * 转介-绑定机构
 */
class ReferralBindModel extends BaseModel
{
    protected $name = 'referral_bind';

    /**
     * 用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind([
            'user_name'=>'name'
        ]);
    }

    /**
     * 绑定机构
     * @return BelongsTo
     */
    public function bindAgency(): BelongsTo
    {
        return $this->belongsTo(ReferralAgencyModel::class, 'agency_id')->bind([
            'agency_name' => 'name',
            'agency_type' => 'type',
            'agency_img' => 'img'
        ]);
    }
}